<template>
    <div class="addUser">
        <el-form ref="form" :model="editData" label-width="150px">
            <el-form-item label="用户名">
                <el-input v-model="editData.customer_name" width="60%"></el-input>
            </el-form-item>
            <el-form-item label="用户密码">
                <el-input v-model="editData.customer_password" width="60%"></el-input>
            </el-form-item>
            <el-form-item label="用户类型">
                <el-select v-model="editData.customer_type" width="60%" placeholder="请选择用户类型">
                    <el-option label="超级会员" value="超级会员"></el-option>
                    <el-option label="普通会员" value="普通会员"></el-option>
                    <el-option label="普通用户" value="普通用户"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="用户年龄">
                <el-input v-model="editData.customer_age" width="60%"></el-input>
            </el-form-item>
            <el-form-item label="用户真实姓名">
                <el-input v-model="editData.customer_reallyName" width="60%"></el-input>
            </el-form-item>
            <el-form-item label="用户性别">
                <el-select v-model="editData.customer_sex" width="60%" placeholder="请选择用户性别">
                    <el-option label="男" value="1"></el-option>
                    <el-option label="女" value="0"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="onSubmit">确 定</el-button>
        </span>
    </div>
</template>

<script>
import { addCustomer } from '../../../api/index';
export default {
    data() {
        return {
            editData:{}
        };
    },
    computed: {
        // editData:function() {
        //     return this.editData
        // }
    },
    watch: {
    },
    methods: {
        onSubmit() {
            console.log(this.editData.customer_age, 'editData');
            console.log(this.editData, 'thisEditData');
            // const params = `customer_id=${this.thisEditData.customer_id}&customer_type=${this.thisEditData.customer_type}`;
            const params = {
                customer_type: this.editData.customer_type,
                customer_age: this.editData.customer_age,
                customer_name: this.editData.customer_name,
                customer_password: this.editData.customer_password,
                customer_reallyName: this.editData.customer_reallyName,
                customer_sex: this.editData.customer_sex
            };
            addCustomer(params).then((res) => {
                console.log(res);
                if (res) {
                    if (res === 'ok') {
                        this.$message({
                            message: '编辑成功',
                            type: 'success'
                        });
                    } else {
                        this.$message.error('编辑失败');
                    }
                }
            });
        }
    },
    props: []
};
</script>

<style scoped>
/* .el-input{
    display: ;
} */
.addUser{
    width: 70%;
}
.dialog-footer{
    margin-left: 250px;
}
</style>